
	{include file="public:header"/} 
{include file="public:sidemenu"/} 
	

		<div class="content-page">
			<!-- Start content -->
			<div class="content">
				<div class="card-box">
					<!-- Row start -->
					<div class="am-g">



    <button style="text-align: center;" ><a href="{:url('jiekou')}">o</a></button></span>    

						<div class="am-g">

                      <div class="am-u-sm-12 am-u-md-3">
                        <div class="am-input-group am-input-group-sm">
                           <div class="input-icon right">
                            <span>
                               <button type="button" class="btn btn-default" data-toggle="modal" data-target="#add_modal"><i class="fa fa-plus" aria-hidden="true"></i></button></span> 
                                </div>
                              </div>
                            </div>
                          </div>
				             <div class="am-u-sm-12">
              <table id="Projects" class="am-table am-table-striped am-table-hover table-main">
                <h2 style="color: gray ;text-align: center;">课程管理</h2>
                <thead>
                  <tr>
                    <th>编号</th>
                  <th>课程图片</th>
                    <th>课程名</th>
                     <th>课程介绍</th>
                      <th>课程价格</th>
                  </tr>
                </thead>
                <tbody>
                {volist name="clubcourses" id="vo"}
                  <tr>
                    <td>{$vo.cc_id}</td>
                    <td><img src="__STATIC__/posters/{$vo.cc_pic}" style="width:100px" ></td>
                    <td>{$vo.cc_name}</td>
                    <td>{$vo.cc_intro}</td>
                    <td>{$vo.cc_price}</td>
                    <td>
                      <div class="am-btn-toolbar">
                        <div class="am-btn-group am-btn-group-xs">
                          <a href="#" data-toggle="modal" data-target="#edit_modal" onclick="jsedit({$vo.cc_id})">修改</a>
                          |
                          <a href="{:url('delete',['id'=>$vo.cc_id])}">删除</a>
                        </div>
                      </div>

                    </td>
                  </tr>
                  {/volist}
                </tbody>
              </table>
            </div> 
				</div>
       </div>
		</div>
	</div>
			
<!-- 添加模态框 -->
<div id="add_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-header">
        <h3 id="myModalLabel">添加课程</h3>
      </div>
      <div class="modal-body">
        <p>
        <form class="form-horizontal" method="post" action="{:url('add')}" enctype="multipart/form-data">

  <div class="form-group">
    <label  class="col-sm-2 am-form-label" for="cc_name" >课程名称</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="cc_name" placeholder="课程名" name="cc_name" required>
    </div>
  </div>

  <div class="form-group">
    <label  class="col-sm-2 am-form-label">课程简介</label>
    <div class="col-sm-10">
       <textarea class="form-control" rows="3" name="cc_intro" required></textarea>
      </div>
</div>


  
   <div class="form-group">
    <label  class="col-sm-2 am-form-label" for="cc_price" >课程价格</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="cc_price" placeholder="价格" name="cc_price" required>
    </div>
  </div>
  
<div class="form-group">
    <label  class="col-sm-2 am-form-label">课程海报</label>
    <div class="col-sm-10">
    <input type="hidden" name="MAX_FILE_SIZE" value="3000000">
        <input type="file" id="exampleInputFile" name="pic" required>
      </div>
  </div>





  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <input type="submit" class="btn btn-default" value="添加">
     <input type="reset" class="btn btn-default" value="重置">
  </div>
  </div>
</form>       


        </p>
      </div>
      <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        <button class="btn btn-primary">Save changes</button>
      </div>
    </div>  
</div>
</div>
<!-- end -->

<!-- 修改模态框 -->
  <div id="edit_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-header">
          <h3 id="myModalLabel">修改课程信息</h3>
        </div>
        <div class="modal-body">
          <p><form method="POST" action="{:url('update')}" enctype="multipart/form-data">
          <input type="hidden" name="cc_id" id="cc_ida">
            <div class="form-group">
              <label for="cc_name" >课程名称</label>
              <div >
                <input type="text" class="form-control" id="cc_nameb" name="cc_name" required>
              </div>
            </div>

            <div class="form-group">
              <label>课程简介</label>
              <div >
                <textarea class="form-control" rows="3" name="cc_intro" id="cc_introb" required></textarea>
              </div>
            </div>

             <div class="form-group">
              <label for="cc_price" >课程价格</label>
              <div >
                <input type="text" class="form-control" id="cc_priceb" name="cc_price" required>
              </div>
            </div>
         
            <div class="form-group">
              <label class="col-md-2 col-xs-2 control-label">课程海报</label>
              <div class="col-md-10 col-xs-10">
                 <input type="hidden" name="MAX_FILE_SIZE" value="5000000" >
                <input type="file" id="exampleInputFilea" name="cc_pic" required>
                <!-- <input type="hidden" name="pic2" id="pic_edit2"> -->
                <img src="__STATIC__/posters/" class="img-thumbnail" id="picb" style="width: 100px">
              </div>
            </div>


    
            </div>

           
            
      

            <div class="form-group">
              <div>
                <input type="submit" class="btn btn-default" value="修改">
                <input type="reset" class="btn btn-default" value="重置">
              </div>
            </div>
          </form>

          </p>
        </div>
      </div>


                           

			
		
		<!-- navbar -->

		<a href="admin-offcanvas" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu" data-am-offcanvas="{target: '#admin-offcanvas'}"><!--<i class="fa fa-bars" aria-hidden="true"></i>--></a>
		
		<script type="text/javascript" src="../assets/js/jquery-2.1.0.js" ></script>
		<script type="text/javascript" src="../assets/js/amazeui.min.js"></script>
		<script type="text/javascript" src="../assets/js/app.js" ></script>
		<script type="text/javascript" src="../assets/js/blockUI.js" ></script>
	</body>
	  {include file="public:footer"/} 

    <script>
      function jsedit(cc_id) {
              //根据TID到数据库里把数据查询到显示在表单控件中
              $.getJSON("{:url('edit')}",{"cc_id":cc_id},
                  function(json) {
                      //alert(json.intro);
                     
                      $("#cc_ida").val(json.cc_id);
                      $("#cc_nameb").val(json.cc_name);
                      $("#cc_introb").val(json.cc_intro);
                      $("#cc_priceb").val(json.cc_price);
                      $("#picb").attr("src","__STATIC__/posters/"+json.cc_pic);
                   
                      /* $("#pic_edit2").val(json.cc_pic);*/
                  });
          }
    </script> 


  
</html>
